package com.daodaofun.service;

import com.daodaofun.dao.ProductDao;
import com.daodaofun.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service("productService")
@Transactional
public class ProductServiceImpl implements  ProductService {
    @Autowired
    private ProductDao productDao;

    @Override
    public List<Product> listAll() {
        return productDao.listAll();
    }

    @Override
    public void addData() {
        for(int i = 0 ; i < 10 ; i ++){
            Product p = new Product();
            p.setName("洗发水" + i);
            p.setPrice(10.5*i+8);
            productDao.save(p);
        }
    }


}
